﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CardLogistics.Web.Components;
using System.Data;
using System.Text;

namespace CardLogistics.Web.MainPage.SelectPage
{
    public partial class SelScrap : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindRpt(1);
            }
        }
        /// <summary>
        /// 绑定Rpt数据
        /// </summary>
        private void BindRpt(int pageIndex)
        {
            int recordCount = 0;
            int pageCount = 0;
            StringBuilder sbStr = new StringBuilder();
            sbStr.Append(" IsSubmit=5 ");
            if (txt_ScrapNo.Text.Trim().Length > 0)
                sbStr.Append(" and SCRAPNO like '%" + txt_ScrapNo.Text.Trim().ToUpper() + "%'");
            if (txt_ScrapStartDate.Text.Trim().Length > 0)
                sbStr.Append(" and to_char(SCRAPDATA,'yyyy-MM-dd')>='" + txt_ScrapStartDate.Text.Trim() + "'");
            if (txt_ScrapEndDate.Text.Trim().Length > 0)
                sbStr.Append(" and to_char(SCRAPDATA,'yyyy-MM-dd')<='" + txt_ScrapEndDate.Text.Trim() + "'");
            DataTable dt = CardLogistics.DAL.CommonData.QuickPage_Oracle("v_cardrecovery_scrap", "ID", " LastUpdateDate desc", WebPageSize, WebPageIndex, sbStr.ToString(), "*", out pageCount, out recordCount);
            SetNetPagerHtml(AspNetPager1, dt, rptList, recordCount);
        }
        /// <summary>
        /// 分页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            WebPageIndex = AspNetPager1.CurrentPageIndex;
            BindRpt(WebPageIndex);
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_Search_Click(object sender, EventArgs e)
        {
            BindRpt(1);
        }
    }
}